/**
 * Create by CaoWenjian
 *
 * @copyRight: 2018
 **/
package com.bjboot.caocao.system.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 *@Description 系统组件配置，配置访问项目外的本地路径
 *@Author 操文健
 *@Date 2018-09-18 下午4:51
 *@Version 1.0
 **/
@Component
public class BJWebConfigurer implements WebMvcConfigurer {

    @Autowired
    private BJBootSysConfigParam bootSysConfigParam;

    /**
     * 将本地文件路径映射到对应到项目访问路径(体现头像访问)
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // application中配置的路径中包含/ 则files:后面是// 否则是///
        registry.addResourceHandler("/files/**").addResourceLocations("file://" + bootSysConfigParam.getUploadPath());
    }
}
